<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        未通过
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../../css/bootstrap.css">
    <link rel="stylesheet" href="../../../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .layui-table-page select {
            height: 22px;
        }
    </style>
</head>

<body>
<div>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>申请/报价单</cite></a>
            <a><cite>报价单</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                            style="line-height:30px">ဂ</i></a>
    </div>
    <div class="main_box">
        <div class="panel-heading">
            <ul class="nav nav-tabs" id="navTabs">
                <li class=""><a class="receivePane" data-tab="" href="quotation.html">我的报价</a></li>
                <li class=""><a class="receivePane" data-tab="" href="quotation_approv.html">我的待办</a></li>
                <li class=""><a class="receivePane" data-tab="" href="myQuotationY.html">已通过</a></li>
                <li class="active"><a class="receivePane" data-tab="" href="myQuotationN.html">未通过</a></li>
                <li class=""><a class="receivePane" data-tab="" href="quotation_profit.html">利润核算</a></li>
            </ul>

        </div>
    </div>

    <form class="layui-form x-center">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item" style="padding-left: 7%">

                <label class="layui-form-label">项目名称</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="projectName" placeholder="项目名称">
                </div>

                <label class="layui-form-label" style="margin-left: 10%;">甲方名称</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="fistName" placeholder="甲方名称">
                </div>

                <label class="layui-form-label" style="margin-left: 10%;">报价人员</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="quotationName" placeholder="报价人员">
                </div>

                <label class="layui-form-label" style="clear: both">审批状态</label>
                <div class="layui-input-inline">
                    <select name="type" lay-search="">
                        <option value="">全部</option>
                    </select>
                </div>

                <label class="layui-form-label" style="margin-left: 10%;">提交状态</label>
                <div class="layui-input-inline">
                    <select name="submitType" lay-search="">
                        <option value="">全部</option>
                    </select>
                </div>

                <label class="layui-form-label" style="margin-left: 10%;">审批人</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="approver" placeholder="审批人">
                </div>

                <label class="layui-form-label" style="clear: both">出库状态</label>
                <div class="layui-input-inline">
                    <select name="partsoutType" lay-search="">
                        <option value="">全部</option>
                    </select>
                </div>

                <label class="layui-form-label" style="margin-left: 10%;">提交日期</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="startTime" id="startTime" placeholder="开始日期">
                </div>
                <label class="layui-form-label">~</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="endTime" id="endTime" placeholder="结束日期">
                </div>

                <label class="layui-form-label" style="clear: both">账单状态</label>
                <div class="layui-input-inline">
                    <select name="priceType" lay-search="">
                        <option value="">全部</option>
                    </select>
                </div>

                <label class="layui-form-label" style="margin-left: 10%;">配件报价</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="startPartsprice" placeholder="最小值">
                </div>
                <label class="layui-form-label">~</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="endPartsprice" placeholder="最大值">
                </div>

                <div class="layui-input-inline layui-show-xs-block">
                    <button class="layui-btn" type="button" lay-filter="sreach" data-type="reload"
                            onclick="reload()">
                        <i class="layui-icon">&#xe615;</i></button>
                </div>

            </div>
        </div>
    </form>


    <div class="layui-card-body">

        <table class="layui-table" id="test" lay-filter="test">
        </table>
    </div>
    <br><br><br><br><br><br>
</div>
</body>
<script type="text/javascript" src="../../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../../js/pub.js"></script>
<script type="text/javascript" src="../../../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../../../js/vue.min.js"></script>
<!-- <script src="lib/layui/layui.js" charset="utf-8"></script> -->
<script src="../../../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element;//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var form = layui.form;
        okLoading.close($);
    });
</script>


<script>

    layui.use(['laydate', 'form'],
        function () {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'datetime',
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'datetime',
                elem: '#end' //指定元素
            });
        });


    layui.use('table', function () {
        table = layui.table;
        let approverIds;
        if($roleId === "4"){
            approverIds = "";
        }else{
            approverIds = $userId;
        }
        var t1 = table.render({
            elem: '#test',
            url: $baseUrl + 'kf/quotation/getQuotationList',
            where: {
                userId: $userId,
                submitType : "1",
                type : "2",
                approverId : approverIds,
            },
            headers: {
                token: $token
            }
            , toolbar: '#toolbarDemo',

            cols: [
                [
                    {
                        field: 'projectname',
                        title: '项目名称',
                    },
                    {
                        field: 'fistname',
                        title: '甲方名称',
                    },
                    {
                        field: 'quotationName',
                        title: '报价人员',
                        width: '7%'
                    },
                    {
                        field: 'partsNumber',
                        title: '配件种类数量',
                        width: '7%'
                    },
                    {
                        field: 'submitTime',
                        title: '报价时间',
                    },
                    {
                        field: 'approver',
                        title: '审批人',
                        width: '7%'
                    },
                    {
                        field: 'partsAllprice',
                        title: '配件总报价',
                        width: '6.1%'
                    },
                    {
                        field: 'partsInstprice',
                        title: '安装总报价',
                        width: '6.1%'
                    },
                    {
                        field: 'type',
                        title: '审批状态',
                        templet(item){
                            if(item.type === '0'){
                                return "未审批";
                            }else if(item.type === '1'){
                                return "已通过";
                            }else if(item.type === '2'){
                                return "未通过";
                            }else{
                                return "未知";
                            }
                        },
                        width: '7%'
                    },
                    {
                        field: 'partsoutType',
                        title: '出库状态',
                        templet(item){
                            if(item.partsoutType === '0'){
                                return "未出库";
                            }else if(item.partsoutType === '1'){
                                return "全部出库";
                            }else{
                                return "未知";
                            }
                        },
                        width: '7%'
                    },
                    {
                        field: 'priceType',
                        title: '账单状态',
                        templet(item){
                            if(item.priceType === '0'){
                                return "未收款";
                            }else if(item.priceType === '1'){
                                return "已收款";
                            }else{
                                return "未知";
                            }
                        },
                        width: '7%'
                    },
                    {
                        field: 'status',
                        title: '操作',
                        // templet: '#barDemo',
                        templet(item) {
                            let detailStr = '<a class="layui-btn layui-btn-xs"  lay-event="detail">详情</a>';
                            return detailStr;
                        },
                        fixed: 'right',
                        width: '15%'
                    }]
            ],
            request: {
                pageName: 'page', //页码的参数名称，默认：page
                limitName: 'size',
            },
            response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                ,
                statusCode: 0 //规定成功的状态码，默认：0
                ,
                msgName: 'msg' //规定状态信息的字段名称，默认：msg
                ,
                countName: 'total' //规定数据总数的字段名称，默认：count
                ,
                dataName: 'data.kfQuotationData', //规定数据列表的字段名称，默认：data
            },
            id: 'test',
            page: true,
            height: 'auto',
            even: true,
            done: function (res, curr, count) {
                //是否有权限或权限是否失效
                // authorizeState();
            }
        });


        //监听工具条
        table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            let data = obj.data; //获得当前行数据
            let layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            if (layEvent === 'detail') { //详情
                admin_add('报价单详情', 'quotation_detail.html?id='+ data.id)
            }
        });

    });

    function admin_add2(title, url, w, h) {
        layer.open({
            type: 2,
            area: [w, h],
            fix: false, //不固定
            maxmin: true,
            shadeClose: true,
            shade: 0.4,
            offset: ['20px', '20px'],
            title: title,
            content: url
        });
    }


    function reload(value) {
        debugger
        table.reload('test', {
            where: {
                projectName: $("input[name=projectName]").val(),
                fistName: $("input[name=fistName]").val(),
                startPartsprice: $("input[name=startPartsprice]").val(),
                endPartsprice: $("input[name=endPartsprice]").val(),
                startTime: $("input[name=startTime]").val(),
                endTime: $("input[name=endTime]").val(),
                quotationName: $("input[name=quotationName]").val(),
                approver: $("input[name=approver]").val(),
                type: $("select[name=type]").val(),
                submitType: $("select[name=submitType]").val(),
                partsoutType: $("select[name=partsoutType]").val(),
                priceType: $("select[name=priceType]").val(),
            }
        });
    }

    function mitss(id){
        let request = {
            url: 'kf/quotation/updateType',
            data: {
                userId: $userId,
                id: id
            },
            method: "GET",
        };
        sendRequest(request, (res) => {
            let d = res.data;
            if(res.code === 0){
                layer.alert("操作成功",{icon: 6})
                let index = layer.getFrameIndex(window.name);
                layer.close(index);
                location.reload();
            } else {
                layer.alert(res.msg, {icon: 5})
            }
        });
        return false;
    }

    function mit(id){
        layer.confirm('确认提交申请单？', {
            btn: ['确认','取消'] //按钮
        }, function(){
            mitss(id);
        }, function(){
        });

    }

    function deless(id){
        let request = {
            url: 'kf/quotation/deleteQuotation',
            data: {
                userId: $userId,
                id: id
            },
            method: "GET",
        };
        sendRequest(request, (res) => {
            let d = res.data;
            if(res.code === 0){
                layer.alert("操作成功",{icon: 6})
                let index = layer.getFrameIndex(window.name);
                layer.close(index);
                location.reload();
            } else {
                layer.alert(res.msg, {icon: 5})
            }
        });
        return false;
    }

    function dele(id){
        layer.confirm('确认删除申请单？', {
            btn: ['确认','取消'] //按钮
        }, function(){
            deless(id);
        }, function(){
        });

    }


    function admin_add(title, url, w, h) {
        layer.open({
            type: 2,
            area: [1000+'px', 700+'px'],
            fix: false, //不固定
            maxmin: true,
            shadeClose: true,
            shade: 0.4,
            title: title,
            content: url
        });
    }

    function admin_open(title, url, w, h) {
        layer.open({
            type: 2,
            area: [w, h],
            fix: false, //不固定
            maxmin: true,
            shadeClose: true,
            shade: 0.4,
            offset: ['20px', '20px'],
            title: title,
            content: url
        });
    }

    setTimeout(() => {
        //审核状态
        let form = layui.form;
        let request = {
            url: 'kf/dictionary/getValue',
            data: {
                userId: $userId,
                dictionaryCode: 'approv_type'
            },
            method: "GET",
        };
        sendRequest(request, (res) => {
            let d = res.data;
            $.each(d, function (index, item) {
                let opt = $("<option value=" + item.type + ">" + item.name + "</option>");
                $("select[name=type]").append(opt);

            });
            form.render('select');
        });

        //提交状态
        let request1 = {
            url: 'kf/dictionary/getValue',
            data: {
                userId: $userId,
                dictionaryCode: 'submit_type'
            },
            method: "GET",
        };
        sendRequest(request1, (res) => {
            let d = res.data;
            $.each(d, function (index, item) {
                let opt = $("<option value=" + item.type + ">" + item.name + "</option>");
                $("select[name=submitType]").append(opt);

            });
            form.render('select');
        });

        //出库状态
        let request2 = {
            url: 'kf/dictionary/getValue',
            data: {
                userId: $userId,
                dictionaryCode: 'partsout_type'
            },
            method: "GET",
        };
        sendRequest(request2, (res) => {
            let d = res.data;
            $.each(d, function (index, item) {
                let opt = $("<option value=" + item.type + ">" + item.name + "</option>");
                $("select[name=partsoutType]").append(opt);

            });
            form.render('select');
        });

        //账单状态
        let request3 = {
            url: 'kf/dictionary/getValue',
            data: {
                userId: $userId,
                dictionaryCode: 'bill_type'
            },
            method: "GET",
        };
        sendRequest(request3, (res) => {
            let d = res.data;
            $.each(d, function (index, item) {
                let opt = $("<option value=" + item.type + ">" + item.name + "</option>");
                $("select[name=priceType]").append(opt);

            });
            form.render('select');
        });

    }, 300)

    layui.use('laydate', function() {
        var laydate = layui.laydate;
        //常规用法
        laydate.render({
            elem: '#startTime'
        });

        laydate.render({
            elem: '#endTime'
        });
    });

</script>

</html>
